//package com.juyu.miliao.scheduler.service;
//
//import com.juyu.miliao.scheduler.dao.mysql.BillDetailDao;
//import com.juyu.miliao.scheduler.dao.mysql.WithdrawalsDao;
//import com.juyu.miliao.scheduler.domin.Withdrawals;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDate;
//import java.util.List;
//
///**
// * @author pengs
// * 主播钻石周结算定时任务
// */
//@Component
//public class WithdrawalsService {
//	private final Logger logger = LoggerFactory.getLogger(WithdrawalsService.class);
//
//	@Autowired
//	private WithdrawalsDao withdrawalsDao;
//	@Autowired
//	private BillDetailDao billDetailDao;
//
//	//周一四点
//	@Scheduled(cron = "0 0 0 ? * MON")
//	public void hostDiamondAccountQuartz() {
//		logger.info("主播钻石周结算定时任务执行");
//		//查询主播的钻石书数据
//		  List<Withdrawals> list = withdrawalsDao.getWithdrawals();
//		  //获取今天是一个星期的第几天
//		  int value = LocalDate.now().getDayOfWeek().getValue();
//		  //获取上周一 00:00:01时间
//		  LocalDate withdrawalsDate = LocalDate.now().minusWeeks(1).minusDays(value-1);
//		  //封装上周钻石时长
//		  list.forEach(w -> {
//			  int lastWeekDiamond =  billDetailDao.getDiamondRecord(w.getUserId());
//			  if (lastWeekDiamond !=0) {
//				  lastWeekDiamond =  billDetailDao.getLastWeekDiamondByUserId(w.getUserId());
//			}
//			  w.setLastweekDiamond(lastWeekDiamond);
//			  w.setWithdrawalsDate(withdrawalsDate);
//              //withdrawalsDao.addWithdrawal(w);
//		  });
//	     //数据写入到提现表
//		withdrawalsDao.addWithdrawals(list);
//		logger.info("主播钻石周结算定时任务结束");
//	}
//}
